import axios from '~/plugins/axios'

const cates = {
  state: {
    cates: [],
    searchCates: []
  },

  mutations: {
    SET_CATES (state, payload) {
      state.cates = payload
    },

    SET_SEARCHCATE(state, payload){
      state.searchCates = payload
    }
  },

  actions: {
    async nuxtServerInit ({commit}) {
      const {data} = await axios.get('/index/findCategoryList').then(data => data.data)
      commit('SET_CATES', data)
    }
  }
}

export default cates
